Imports System
Imports System.Data
Imports System.Data.Common
Imports System.Collections.Generic

Imports ACFramework
Imports DAConexion
Imports Microsoft.Practices.EnterpriseLibrary.Data
Imports Microsoft.Practices.EnterpriseLibrary.Data.Sql

Public Class Form1

   Private _listTramites As New List(Of ETDC_Tramites)()
   Private bs_bindingsource As New BindingSource()

   Private Sub ToolStripButton1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton1.Click
      'Dim _dataset As DataSet
      'Dim dtdetalle As DataTable

      _listTramites = New List(Of ETDC_Tramites)()
      DAEnterprise.AsignarProcedure("Select * from TDC_Tramites", CommandType.Text)

      Using reader As DbDataReader = DAEnterprise.ExecuteDataReader()
         If reader.HasRows Then
            Dim _nsesquemas As New ACEsquemas(New ETDC_Tramites)
            While reader.Read()
               Dim e_tdc_tramites As New ETDC_Tramites()
               _nsesquemas.ACCargarEsquemas(reader, e_tdc_tramites)
               e_tdc_tramites.Instanciar(ETDC_Tramites.Instancia.Consulta)
               _listTramites.Add(e_tdc_tramites)
            End While
         Else
         End If
      End Using

      bs_bindingsource = New BindingSource()
      bs_bindingsource.DataSource = _listTramites

      c1grdGrilla.DataSource = bs_bindingsource


      'exec VEN_PRODSS_BusquedaListaPrecios @ALMA_Codigo = N'001', @Familia = NULL, @Marca = NULL, @Moneda = N'001', @SUCR_Codigo = N'01', @TIPO_CodFactor = N'001', @TIPO_TabFactor = N'FCV', @TipoProd = N'001'
      'DAEnterprise.AsignarProcedure("VEN_PRODSS_BusquedaListaPrecios ")
      'DAEnterprise.AgregarParametro("@ALMA_Codigo", "001")
      'DAEnterprise.AgregarParametro("@Familia", System.DBNull.Value)
      'DAEnterprise.AgregarParametro("@Marca", System.DBNull.Value)
      'DAEnterprise.AgregarParametro("@Moneda", "001")
      'DAEnterprise.AgregarParametro("@SUCR_Codigo", "01")
      'DAEnterprise.AgregarParametro("@TIPO_CodFactor", "001")
      'DAEnterprise.AgregarParametro("@TIPO_TabFactor", "FVC")
      'DAEnterprise.AgregarParametro("@TipoProd", "001")

      'exec VEN_DDOVSS_Utilidades22 @FechaFin = 'Sep 30 2009 12:00:00:000AM', @FechaInicio = 'Sep 1 2009 12:00:00:000AM', @SUCR_Codigo = NULL
      'DAEnterprise.AsignarProcedure("VEN_DDOVSS_Utilidades22")
      'DAEnterprise.AgregarParametro("@FechaFin", "Sep 30 2009 12:00:00:000AM")
      'DAEnterprise.AgregarParametro("@FechaInicio", "Sep 1 2009 12:00:00:000AM")
      'DAEnterprise.AgregarParametro("@SUCR_Codigo", System.DBNull.Value)

      '_dataset = DAEnterprise.ExecuteDataSet
      'dtdetalle = _dataset.Tables(0)
      'NSFramework.NSFramework.NSPivotTable.NSSetCabecerasPivot(c1grdGrilla, dtdetalle, New String() {"PRODUCTO", "MARCA", "UNIDAD"}, "SUCURSALES", "SUCRCodigo", 2)
      'dtdetalle = NSFramework.NSFramework.NSPivotTable.NSPivotTable(dtdetalle, New String() {"PRODUCTO", "MARCA", "UNIDAD"}, "SUCURSALES", "Pivot", False)
      'c1grdGrilla.DataSource = dtdetalle
   End Sub

   Public Sub New()
      ' This call is required by the Windows Form Designer.
      InitializeComponent()
      ' Add any initialization after the InitializeComponent() call.
      DAEnterprise.Instanciar("StrConn")
   End Sub

   Private Sub ToolStripButton2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton2.Click
      Dim _buscador As New ACBuscador(Of ETDC_Tramites)()
      Dim _index As Integer = -1

      _buscador.ACBusqueda = "TRAM_NroAlterno=" & tstxtBusqueda.Text
      _index = _buscador.ACBuscar(_listTramites)
      If _index > -1 Then
         ACControles.ACDialogos.ACMostrarMensajeSatisfactorio("Buscar", "SI se encontro el elemento")
      Else
         ACControles.ACDialogos.ACMostrarMensajeError("Buscar", "NO se encontro el elemento", New Exception(""))
      End If
      bs_bindingsource.Position = _index
   End Sub
End Class
